import javax.swing.JPanel;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

import javax.imageio.ImageIO;

import javax.swing.*;

public class drawcircle extends JFrame{
    private MyPanel mp=null;
    public static void main(String[] args) {
        new drawcircle();
    }
    public drawcircle(){
        //初始化面板
        mp=new MyPanel();
        this.add(mp);
        //上设置窗口大小
        this.setSize(400,400);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }
}
class MyPanel extends JPanel{ 
    @Override
    public void paint(Graphics g) {
        // TODO Auto-generated method stub
        super.paint(g);//调用父类方法完成初始化
        System.out.println("被调用了");
        //g.drawOval(10, 10, 300, 300);

        //g.drawLine(10, 10, 300, 300);
        //g.drawRect(10, 10, 150, 150);
        //g.setColor(Color.blue);
        //g.fillRect(10, 10, 100, 100);
        //g.setColor(Color.RED);
        //g.setFont(new Font("隶书",Font.BOLD,20));
        //g.drawString("北京你好", 100, 100);
        g.drawLine(200, 200, 200,100 );
        g.drawOval(180, 150, 40, 40);
        g.drawRect(170, 130, 60, 90);
        g.drawRect(140, 110, 30, 120);
        g.drawRect(230, 110, 30, 120);

    }
}